require 'statistic/fields_counter'
require 'json/add/rails'

module Statistic
  
  class JSONFieldsCounter < FieldsCounter
    
    def initialize( crawl_table, conditions = "status = 200" )
      super crawl_table, conditions
    end
    
    def analyse(c)
      js = JSON.parse(c.body)
      js.each_key { |k| @fields_stat[k] += 1 unless js[k].nil? || js[k].eql?("") }
    end
    
  end
  
end # module Statistic